/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.commands;

/**
 * @author PlayDK
 */
public enum PlayerGMRank {

    NORMAL('@', "普通玩家"),
    DONATOR('#', "活动管理员"),
    SUPERDONATOR('$', "超级活动管理员"),
    INTERN('%', "实习GM"),
    GM('!', "普通GM"),
    SUPERGM('!', "超级GM"),
    ADMIN('!', "管理员"),
    CHAT('-', "普通聊天");
    private final char commandPrefix;
    private final String name;

    PlayerGMRank(char ch, String name) {
        this.commandPrefix = ch;
        this.name = name;
    }

    public char getCommandPrefix() {
        return commandPrefix;
    }

    public String getName() {
        return name;
    }

    public static PlayerGMRank getPlayerGMRankByLevel(int level) {
        return values()[level];
    }

    public static PlayerGMRank getPlayerGMRankByCommandPrefix(char commandPrefix) {
        for (PlayerGMRank rank : values()) {
            if (rank.commandPrefix == commandPrefix) {
                return rank;
            }
        }
        return null;
    }

    public static boolean isGMCommandPrefix(char commandPrefix) {
        return INTERN.getCommandPrefix() == commandPrefix || GM.getCommandPrefix() == commandPrefix || SUPERGM.getCommandPrefix() == commandPrefix || ADMIN.getCommandPrefix() == commandPrefix;
    }

    public static boolean isPlayerCommandPrefix(char commandPrefix) {
        return NORMAL.getCommandPrefix() == commandPrefix || DONATOR.getCommandPrefix() == commandPrefix || SUPERDONATOR.getCommandPrefix() == commandPrefix;
    }

    public int getLevel() {
        return ordinal();
    }
}
